#ifndef __LOGIC_H
#define __LOGIC_H

#include "main.h"
#include "LED.h"
#include "UART.h"
#include "usart.h"
#include "wireless_uart.h"

typedef enum
{
    Logic_Mode = 1,
    Map_Mode = 2
}UVA_Mode;

typedef enum
{    
    None_Fly  = 0,      //无
    Ready_Fly = 1,      //准备飞行
    Mid_Flight = 2,     //飞行中
    Stop_Fly = 3,       //停止飞行
    Receiced_Fly = 4    //电脑返回飞行状态
}Fly_State;

typedef enum
{    
    None_Clear = 1,
    Ready_Clear = 2
}Clear_State;

typedef struct
{
    uint8_t Head;
    Fly_State fly_state;
    uint8_t Data[256];
    uint8_t MAP[256];
    Clear_State  clear_state;  
    uint8_t Tail;
    /* data */
}Screen_Date;

typedef struct
{
    uint8_t Head;
    uint8_t Data[350];
    uint8_t Data_Last[350];
    Fly_State Fly_State;
    uint8_t Mid_Date[10];
    uint8_t Tail;
    /* data */
}UVA_Date;

//创造暂存队列
typedef struct 
{
    uint8_t Location;
    uint8_t Elephabt;//大象数量
    uint8_t Peacock;//孔雀
    uint8_t Monkey;
    uint8_t Tiger;
    uint8_t Wolf;
    /* data */
}Animal_Date;


extern Animal_Date animal_date[80];




typedef struct
{
    uint8_t Head;
    Fly_State Computer_Fly_State;
    uint8_t Tail;
    /* data */
}Computer_Date;

extern Screen_Date Screen_date;
extern UVA_Date UVA_date;

//无人机起飞逻辑帧头帧尾
#define UVA_Logic_Head 0xD0
#define UVA_Logic_Tail 0xE0
//无人机地图帧头帧尾
#define UVA_Map_Head 0xD1
#define UVA_Map_Tail 0xE1
//
#define UVA_Recive_Head 0xD3
#define UVA_Recive_Tail 0xE3

//无人机状态
#define UVA_Recive_State_Head 0xDF
#define UVA_Recive_State_Tail 0xEF

//无人机识别信息
#define UVA_Recive_Animal_Head 0xFD
#define UVA_Recive_Animal_Tail 0xEC

//串口屏帧头
#define Usart_Screen_Head 0xA5// 坐标
#define Usart_Screen_Head_Fly 0xA6// 起飞
#define Usart_Screen_Head_Clear 0xA7//清屏
#define Usart_Screen_Head_Animals 0xA8//动物
//串口屏帧尾
#define Usart_Screen_Tail 0xE1



extern int8_t len[100];
extern usart Usart_2_4G,Usart_Screen,Usart_Text;
extern uint8_t Animal_N,animal_date_num;
extern uint8_t Temp[80];

void logic_Init(void);
void logic_task(uint8_t Mode);
void Show_Text(void);
void Draw_Line(void);
void UsartSCreenData(uint8_t *buff);
void UVA_Date_Text(usart Usart,uint8_t length,uint8_t Temp[]);
void Animal_Location(uint8_t date[10]);


/**
 * @brief 处理接收到的数据，判读数据是否重复，是否超过，存储数据，有无动物等
 * @param Mid//接收数据包
 */
void Animal_Date_Processing(uint8_t Date[10]);
void Printf_Animal(void);



#endif // !__LOGIC_H

